{% extends "autotester/base.html" %}
{% block title%}API列表{% endblock%}
{% block content %}
    <div class="row">
        <div class="col-sm-5">
            <ol class="breadcrumb">
                <li><a href="/autotester/projects">项目</a></li>
                <li><a href="/autotester/project/{{ module.project.id }}">{{ module.project.name }}</a></li>
                <li class="active">
                {{ module.name }}</ol>
            (该模块由<a href="javascript:;"
                    class="profile">{{ module.created_user.username }}</a>于{{ module.created_time|date:"Y年m月d日 H:i:s" }}添加)</li>
        </div>
        <div class="col-sm-7">
            <div class="title-action">
                {% if perms.script.add_api %}
                    <div><a class="btn btn-primary pull-right" href="/autotester/api/create/{{ module.id }}">+添加API</a>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>

	<div class="row">

		<table class="table table-striped table-hover table-condensed">
			<thead>
				<tr>
					<th>ID</th>
					<th>名称</th>
					<th>URL</th>
					<th>请求方式</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				{% for api in apis%}
					<tr>
						<td>{{ api.id }}</td>
						<td><a href="/autotester/cases/{{api.id}}">{{ api.name }}</a></td>
						<td>{{ api.url }}</td>
						<td>{{ api.method }}</td>
                        <td>
                        {% if api.status%}
                        {% if perms.script.change_api%}

                            <a class="btn" href="/autotester/cases/{{api.id}}" data-toggle="tooltip" data-placement="bottom" title="查看case"><span class="glyphicon glyphicon-eye-open"></span></a>
                            {% if perms.script.change_api%}
                            <a class="btn" href="/autotester/api/edit/{{api.id}}" data-toggle="tooltip" data-placement="bottom" title="编辑"><span class="glyphicon glyphicon-edit"></span></a>
                            <a class="btn" href="/autotester/api/inactive/{{api.id}}" data-toggle="tooltip" data-placement="bottom" title="禁用"><span class="glyphicon glyphicon-trash"></span></a>
                            {% endif %}
                            <a class="btn" href="/autotester/cases/test/{{api.id}}" data-toggle="tooltip" data-placement="bottom" title="Run Test"><span class="glyphicon glyphicon-flash"></span></a>
                            <a class="btn" href="/autotester/api/report/{{api.id}}" data-toggle="tooltip" data-placement="right" title="查看报告"><span class="glyphicon glyphicon-list-alt"></span></a>


                        {% endif%}
                        {% else %}
						    <a class="btn" href="/autotester/api/active/{{api.id}}" data-toggle="tooltip" data-placement="right" title="激活"><span class="glyphicon glyphicon-pushpin"></span></a>
                        {% endif %}
                        </td>                        
                    </tr>
				{% endfor %}
			</tbody>
		</table>
	</div>
{% endblock %}